package com.employee.controller;

import com.employee.pojo.dto.AgreeDTO;
import com.employee.pojo.dto.ReqDTO;
import com.employee.pojo.dto.ReqInfoDTO;
import com.employee.pojo.entry.Clock;
import com.employee.pojo.result.PageResult;
import com.employee.pojo.result.Result;
import com.employee.pojo.vo.ClockVO;
import com.employee.pojo.vo.ReqVO;
import com.employee.service.ClockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ClockController {

    @Autowired
    private ClockService clockService;


    // 打卡上班
    @GetMapping("/clockIn")
    public Result<Clock> clockIn () {
        return Result.success(clockService.clockIn());
    }

    // 打卡下班
    @GetMapping("/clockOut")
    public Result<Clock> clockOut () {
        return Result.success(clockService.clockOut());
    }

    // 获取打卡信息
    @GetMapping("/getClock")
    public Result<ClockVO> getClock () {
        return Result.success(clockService.getClock());
    }

    // 未打卡
    @GetMapping("/notClock")
    public Result<PageResult<ReqVO>> notClock (ReqInfoDTO reqInfoDTO) {
        return Result.success(clockService.notClock(reqInfoDTO));
    }

    @GetMapping("/AddClock")
    public Result<ReqDTO> AddClock (ReqDTO reqDTO) {
        System.out.println(reqDTO);
        clockService.AddClock(reqDTO);
        return Result.success();
    }

    @PostMapping("/agreeReq")
    public Result AgreeReq (@RequestBody AgreeDTO agree) {
        clockService.AgreeReq(agree);
        return Result.success();
    }
}
